package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.InputStreamReader;


public class ReturnAnItem implements Action {
    private Library library;
    LoginManager loginManager;

    ReturnAnItem(Library library, LoginManager loginManager) {
        this.library = library;
        this.loginManager = loginManager;
    }

    public void execute() throws Exception {
        String nameOfItem;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter name of Item you want to return : ");
        nameOfItem = br.readLine();
        library.returnBorrowedItem(loginManager.currentUser, Integer.parseInt(nameOfItem));
        System.out.println("Item returned successfully");
    }

    @Override
    public String printActionName() {
        return "Return an Item";
    }
}
